14. Practice Replacing a Fragment

Replace a fragment

Given the following starting code:

FragmentManager fm = getSupportFragmentManager();
Fragment frag = new BodyPartFragment();
int containerID = R.id.fragment_container;
FragmentTransaction ft = fm.beginTransaction();

Complete the transaction code to replace the fragment container with a new BodyPartFragment.

SOLUTION: ft.replace(containerID, frag). commit();